# for checking something is valid user input
import math
# int
def numcheck(string, soort):
    if soort == "integer":
        try:
            float(string) 
            returndict = {}
            if int(string):
                returndict['integer'] = abs(int(string))
                return returndict
            elif float(string):
                returndict['integer'] = abs(math.floor(string))
                return returndict
        except ValueError:
            return False
    elif soort == "float":
        try:
            float(string) 
            returndict = {}
            if isinstance(string, int):
                returndict['float'] = float(string) 
                return returndict
            elif isinstance(string, float):
                returndict['float'] = float(string)
                return returndict
        except ValueError:
            return False
# string checking should match input (for instance names of tables) to a list of options
def stringcheck(string, lijst):
    returndict = {}
    if string in lijst:
        returndict['exists'] = string
        return returndict
    else:
        return False


